import logging

import pytest

from common.json_read_tuplelist import json_read

from api.base import UserGL, Address
from common.log_use import init_log_config
from config import BASE_DIR


class TestLogin:
    def setup_class(self) -> None:
        pass
    def teardown_class(self) -> None:
        init_log_config(BASE_DIR + '/log/app.log')
        logging.debug('测试结束')

    @pytest.mark.parametrize('desc,data,code_status,success,message',json_read('data/zcdata.json'))
    def test_zc(self,desc,data,code_status,success,message):
        resp = UserGL.user_zc(data)
        UserGL.assert_user(resp,code_status,success,message)

    @pytest.mark.parametrize('desc,data,status_code,success,message',json_read('data/dldata.json'))
    def test_dl(self,desc,data,status_code,success,message):
        resp = UserGL.user_dl(data)

        UserGL.assert_user(resp,status_code,success,message)
    @pytest.mark.parametrize("desc,data,success,message",json_read("data/add_data.json"))
    def test_add_address(self,desc,data,success,message):
        resp =  Address.add_address(data)
        Address.assert_address(resp,success, message)

    @pytest.mark.parametrize("desc,data,success,message", json_read("data/delete_adddata.json"))
    def test_delect_address(self, desc, data, success, message):
        resp = Address.delete_address( data)
        Address.assert_address(resp, success, message)
    # #
    @pytest.mark.parametrize("desc,data,success",json_read("data/select_adddata.json"))
    def test_select_address(self,desc,data,success):
        resp = Address.get_address(data)
        Address.assert_address_select(resp,success)
    @pytest.mark.parametrize("desc,data,success,message",json_read("data/mr_adddata.json"))
    def test_mr_address(self,desc,data,success,message):
        resp = Address.mr_address(data)
        Address.assert_address(resp,success,message)

